<%@page import="java.sql.ResultSet"%>
<%@page import="javabean.JDBCBean"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>添加快递员</title>
  <!-- layui -->
  <link rel="stylesheet" href="../public/layui/css/layui.css">
  <script src="../public/layui/layui.js"></script>
  <script src="../js/jquery.min.js"></script>
  <style>
    .layui-form{
      margin: 10px 20px;
      
    }
  </style>
  </style>
</head>
<body>
<%--  <%--%>
<%--	ResultSet librarySet = null;--%>
<%--	ResultSet bookSortSet = null;--%>
<%--	// 获取图书馆列表--%>
<%--	JDBCBean db2 = new JDBCBean();--%>
<%--	String librarySql = "select * from library";--%>
<%--	librarySet = db2.executeQuery( librarySql );--%>
<%--	// 获取书籍分类--%>
<%--	JDBCBean db3 = new JDBCBean();--%>
<%--	String bookSortSql = "select * from book_sort";--%>
<%--	bookSortSet = db3.executeQuery( bookSortSql );--%>
<%--  %>--%>
    <form class="layui-form   layui-form-pane" action="">
  <input type="id" name="id" value="3" class="layui-hide">
  <div class="layui-form-item">
        <label class="layui-form-label">账号</label>
        <div class="layui-input-block">
          <input type="text" name="pid" required="" lay-verify="required" placeholder="请输入账号" autocomplete="off" class="layui-input">
        </div>
      </div>
  <div class="layui-form-item">
    <label class="layui-form-label">姓名</label>
    <div class="layui-input-block">
      <input type="text" name="name" required="" lay-verify="required" placeholder="请输入快递员姓名" autocomplete="off" class="layui-input">
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">密码</label>
    <div class="layui-input-block">
      <input type="text" name="psw" required  lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">管辖区域</label>
    <div class="layui-input-block">
      <input type="text" id="area" name="area" required="" lay-verify="required" placeholder="请输入区域编号"  autocomplete="off" class="layui-input" readonly>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">联系方式</label>
    <div class="layui-input-block">
      <input type="text" name="phonenumber"required  lay-verify="required" placeholder="请输入联系方式" autocomplete="off" class="layui-input">

    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit="" lay-filter="bookForm">立即提交</button>
    </div>
  </div>
</form>
<script>
  $(function(){

    <%
                                        Object admin=session.getAttribute("admin");
                                        String area =admin.toString();
     %>
    document.getElementById("area").value="<%=area%>";
    // var str =document.getElementById("ISBN");
    // var isbn = document.createAttribute("ISBN");
    // isbn.value=st
  })
</script>
<script>


layui.use(['form', 'layedit', 'jquery'], function(){
	  //layer.closeAll();
	  $ = layui.jquery;
	  var form = layui.form
	  ,layer = layui.layer
	  ,layedit = layui.layedit;
	  /**
	   * 因为富文本存在xss注入，以下代码不用了，如果需要可以开启
	   */
	  /* 
	  var editIndex = layedit.build('LAY_demo_editor');
	  // 自定义验证规则
	  form.verify({
		  // 解决富文本异步传输问题
		  content: function(value){
			  return layedit.sync(editIndex);
		  }
	  }) 
	  */
	  //监听提交
	  form.on('submit(bookForm)', function(data){
	    $.ajax({
	    	url: './postmanAdd',
	    	method: 'post',
	    	data: data.field, //JSON.stringify(data.field),
	    	dataType: 'JSON',
	    	success: function(data){
	    		if(data.code == "0"){
	    			parent.layer.msg("添加成功",{
	    				icon: 6,
	    				time: 500
	    			});
	    			setTimeout(function(){
	    				//parent.location.reload();
	    				var index = parent.layer.getFrameIndex(window.name); //操作父页面
	            		parent.layer.close(index);
	    			}, 500);
	    		}else{
	    			leyer.msg("添加失败");
	    		}
	    	}
	    })
	    
	    
	    return false;
	  });
	});

</script>

</body>
</html>